<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="js/jquery-3.3.1.js"></script>
    <title>UserControl</title>
    <style>
        #control_content{
            width: 800px;
            height: 500px;
            margin: 50px auto;
            border: 1px red solid;
        }
        #buy_token_div {
            display: none;
        }

    </style>

    <script>
        $(document).ready(function () {
            $("#buy_token_button").click(function () {
                $("#buy_token_div").css("display","block");
                $(this).hide();
            });

            $("#address_div").text(localStorage["name"]);

            $("#query_balance_button").click(function () {
                $.get("/query_balance",{
                    address:localStorage["name"]
                },function (data,status) {
                    $("#address_span").text(data.data);
                })
            });

            $("#buy_token_submit").click(function () {
                var count = $("#token_count_input").val();
                $.get("/buy_token",{
                    address:localStorage["name"],
                    count:count
                },function (data, status) {
                    if (status === "success"){
                        if (data.status === 0){
                            $("#control_content").load("token_manager.html");
                        }else{

                        }
                    }
                })
            })
        })
    </script>


    <link rel="icon" href="images/hao.gif" type="image/x-icon">
</head>
<body>

<div id="control_content">
    <div >地址信息:</div>
    <p id="address_div"></p>
    <br/>
    <button type="button" id="query_balance_button">查询账户余额</button><span id="address_span"></span>
    <br/>
    <br/>
    <br/>
    <br/>
    <button type="button" id="buy_token_button">购买代币</button>

    <div id="buy_token_div">
        请输入代币数量:<input type="text" id="token_count_input"/>
        <button type="button" value="submit" id="buy_token_submit">提交</button>
    </div>


</div>


</body>
</html>